package itesm.sql.data;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionDB {
	
	private Connection connectionDB = null;

	//Vrd que si?  : O
	public ConnectionDB() throws ClassNotFoundException, SQLException{
		
		String host = "localhost"; 
	      Class.forName("com.mysql.jdbc.Driver");
	 	   String url = "jdbc:mysql://"+host+"/wavecoler", 
	 	          user="root",
	 	          password="132410jh";  
			connectionDB = DriverManager.getConnection(url, user, password);
	}
	
	public ConnectionDB(String driver, String url, String user,String password){
		try{
			Class.forName(driver);
			connectionDB = DriverManager.getConnection(url,user,password);
		}catch(SQLException e){
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Connection getConnectionDB(){
		return connectionDB;
	}
	
	public void setConnectionDB(Connection connectionDB){
		this.connectionDB = connectionDB;
	}
	
	public void closeConnectionDB(){
		if(connectionDB!=null){
			try{
				connectionDB.close();
			}catch(SQLException e){
				e.printStackTrace();
			}
		}
	}
	
}
